#-*-coding:utf-8-*-
__author__ = 'toriycn'

class BaseService(object):

    def __init__(self):
        #服务名称
        self.name ="BaseService"
        #时间间隔
        self.interval = 300
        #插件名称
        self.plugin_name='your_plugin_name'
        #触发列表
        self.triggers={}

class CPU(BaseService):

   def __init__(self):
      super(CPU,self).__init__()
      self.interval = 30
      self.name = "linux_cpu"
      self.plugin_name ="get_cpu_status"

      self.triggers = {
        'idle' : {
           'func':'avg',
           'last':10*60,
           'count' : 1,
           'operator': 'lt',
           'warning' : 45,
           'critical' : 55,
           'data_type': float
        },
        'iowait':{
            'func': 'hit',
            'last': 15*60,
            'count' : 5,
            'operator': 'gt',
            'warning' : 90,
            'critical' : 92,
            'data_type': float
        },'user':{
            'func': 'avg',
            'last': 15*60,
            'count' : 5,
            'operator': 'gt',
            'warning' : 30,
            'critical' : 60,
            'data_type': float
        }
      }

class Memory(BaseService):
    def __init__(self):
        super(Memory,self).__init__()
        self.interval = 20
        self.name = "linux_mem"
        self.plugin_name ="get_mem_status"

        self.triggers = {
           'useage':{
               'func':'avg',
               'last':5*60,
               'count' : 1,
               'operator': 'gt',
               'warning' : 80,
               'critical' : 90,
               'data_type': float
           }
        }

class Network(BaseService):

    def __init__(self):
        super(Network,self).__init__()
        self.interval = 60
        self.name = "linux_network"
        self.plugin_name ="get_network_status"

        self.triggers = {
            'in':{
                'func':'hit',
                'last':5*60,
                'count' : 5,
                'operator': 'gt',
                'warning' : 1024*1024*10,
                'critical' : 1024*1024*30,
                'data_type': float
            },
            'out':{
                'func':'hit',
                'last':5*60,
                'count' : 1,
                'operator': 'gt',
                'warning' : 1024*1024*10,
                'critical' : 1024*1024*20,
                'data_type': float
            }
        }

